package mapper;

import javabean.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from users where username=#{username} and password=#{password} and status=1")
    User selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);

    List<User> selectUser_Role();

    User selectUser_RoleById(int id);

    int insert(User user);
    @Insert("insert into users_role (userId,roleId) values(#{uid},#{rid})")
    int insertU_R(@Param("uid") int uid,@Param("rid") int rid);

    @Update("update users set email=#{email},username=#{username},password=#{password},phoneNum=#{phoneNum},`status`=#{status} where id=#{id}")
    int updateById(User user);
    @Update("update users_role set roleId=#{rid} where userId=#{uid}")
    int updateU_R(@Param("uid") int uid,@Param("rid") int rid);

    @Delete("delete from users where id=#{id}")
    int deleteById(int id);

    @Delete("delete from users_role where userId=#{id}")
    int deleteU_R(int id);
}